<?php

# desc: create database and import directory "demodir" into database

try
{
    date_default_timezone_set('UTC');

    require_once(dirname(__FILE__)."/../config/conf.php");
    
    $link = mysql_connect(DemoConfig::$host, DemoConfig::$username, DemoConfig::$password); 

    # create database
    $sql = 'CREATE DATABASE demo';
    mysql_query($sql, $link);

    # use database 
    mysql_select_db(DemoConfig::$dbname, $link);

    # create tables
    $sql = file_get_contents(dirname(__FILE__).'/schema.sql');
    echo $sql;
    mysql_query($sql, $link);
}
catch (Exception $e)
{
    echo $e->getMessage() . PHP_EOL;
    return false;
}

